// "".match(/\d+/g)
// const _ = require("lodash");

//手动实现函数柯理化
const match = curry(function(reg,str){
  return str.match(reg);
})

const matchSpace = match(/\s+/g);
const matchNumber = match(/\d+/g);

console.log(matchNumber("dadas2131das312"));

const filter = curry(function(fn,array){
  return array.filter(fn)
})
console.log(filter(matchSpace,["hsjdh  fsdfkjdsh fsdf","djsdf"]));
const filterSpace = filter(matchSpace);
console.log(filterSpace(["hsjdh  fsdfkjdsh fsdf","djsdf"]))
console.log(filter(matchNumber,["dasd13sd","dasdas"]))
const filterNum = filter(matchNumber);
console.log(filterNum(["dasd13sd","dasdas"]))

function curry(fn){
  return function curryFn(...args){
    if(args.length < fn.length){
      return function(){
        return curryFn(...args.concat([...arguments]))
      }
    }
    return fn(...args);
  }
}
